package com.hearing.calltest.main;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hearing.calltest.R;
import com.hearing.calltest.data.DataSource;
import com.hearing.calltest.detail.DetailActivity;
import com.hearing.calltest.util.SPUtil;

public class MainActivity extends AppCompatActivity {

    private MyAdapter mVideoAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    private void init() {
        SPUtil.getInstance(this);
        RecyclerView videoRecycleView = findViewById(R.id.video_rv);
        videoRecycleView.setLayoutManager(new LinearLayoutManager(this));

        mVideoAdapter = new MyAdapter();
        videoRecycleView.setAdapter(mVideoAdapter);

        mVideoAdapter.setOnItemClickListener((index) -> {
            String path = mVideoAdapter.getData(index);
            DetailActivity.startSelf(this, path);
        });
        mVideoAdapter.setData(DataSource.getVideoList());
    }
}